package com.azdebugit.result.common;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Optional;

public class ExtraParamUtil {
    private static final ThreadLocal<ExtraParam> extraParamLocal = new TransmittableThreadLocal();
    public static final Map<String, String> map = Maps.newHashMap();

    public ExtraParamUtil() {
    }

    public static ExtraParam getExtraParam() {
        if (!Optional.ofNullable(extraParamLocal.get()).isPresent()) {
            extraParamLocal.set(new ExtraParam());
        }

        return (ExtraParam)extraParamLocal.get();
    }

    public static void setExtraParam(ExtraParam extraParam) {
        extraParamLocal.set(extraParam);
    }

    public static void destroy() {
        extraParamLocal.remove();
    }

    public static void main(String[] args) {
        getExtraParam().setTenantId(1L);
        System.out.println(getExtraParam().getTenantId());
        Thread thread = new ExtraParamUtil.MyThreadTo();
        thread.start();

        try {
            thread.join();
        } catch (InterruptedException var3) {
            var3.printStackTrace();
        }

    }

    private static class MyThreadTo extends Thread {
        private MyThreadTo() {
        }

        public void run() {
            System.out.println(ExtraParamUtil.getExtraParam().getTenantId());
        }
    }
}